<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/5/22
  Time: 17:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改资源策略</title>
</head>
<body>
<div style="border: 1px solid #E6E6E6;width: 350px;margin:auto;">
    <form id="editResourceStrategyForm" style="margin-top: 20px;font-size: 15px;font-family: 微软雅黑;">
        <input type="hidden" name="id">
        <div style="margin-bottom:20px;text-align: center;">
            <input id="type_comb_edit" name="type">
        </div>
        <div style="margin-bottom:20px;text-align: center;">
            <input id="id_comb_edit" name="resource_id">
        </div>
        <div style="margin-bottom:20px;text-align: center;">
            <input class="easyui-textbox" name="cycle" data-options="label:'周期',width:300,height:30,required:true,missingMessage:'周期不能为空！'">
        </div>
        <div style="margin-bottom:20px;text-align: center;">
            <input class="easyui-textbox" name="price" data-options="label:'价格',width:300,height:30,required:true,missingMessage:'价格不能为空！'">
        </div>
    </form>
    <div style="text-align:center;padding:5px 0">
        <a class="easyui-linkbutton" onclick="$('#editResourceStrategyForm').form('submit');" style="width:80px">提交</a>
        <a class="easyui-linkbutton" onclick="$('#editResourceStrategyForm').form('clear');" style="width:80px">重置</a>
    </div>
</div>
<script>
    $(function () {
        $('#editResourceStrategyForm').form({
            url:'../resourceStrategy/updateResourceStrategy',
            type:'post',
            success:function(data){
                var data = eval('(' + data + ')');
                if (data.result === 'success') {
                    $('#editResourceStrategyForm').form('clear');
                }
                $.messager.alert('提示', data.message, 'info');
            }
        });

        $('#type_comb_edit').combobox({
            valueField:'id',
            textField:'text',
            data:[{
                id:"应用", text:"应用"
            },{
                id:"功能模块", text:"功能模块"
            },{
                id:"功能", text:"功能"
            },{
                id:"主机", text:"主机"
            },{
                id:"带宽", text:"带宽"
            }],
            label:'资源类型',
            width:300,
            height:30,
            editable:false,
            required:true,
            missingMessage:'资源类型不能为空！',
            onSelect: function(rec){
                var url;
                if (rec.id === '应用') {
                    url = '../application/findAllApplications';
                } else if (rec.id === '功能模块') {
                    url = '../funcModule/findAllFuncModuleCustom';
                } else if (rec.id === '功能') {
                    url = '../func/findAllFuncCustom';
                } else if (rec.id === '主机') {
                    url = '../host/findAllHostCustom';
                } else {
                    url = '../bandwidth/findAllBandwidths';
                }
                $('#id_comb_edit').combobox('reload', url);
            }
        });

        $('#id_comb_edit').combobox({
            valueField:'id',
            textField:'id',
            label:'资源id',
            width:300,
            height:30,
            editable:false,
            required:true,
            missingMessage:'资源id不能为空！'
        });

        var row = $('#resourceStrategy_dg').datagrid('getSelected');
        $('#editResourceStrategyForm').form('load', row);
    });
</script>
</body>
</html>
